<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js"></script>
<script type="text/javascript">
function updatecatmember(ref){
	text = document.getElementById("pass_"+ref).value;
	url = "<?php echo base_url();?>"+"/addmincont/updateMember/";
	var data ={'ref':ref,'name':text};
	if(text.length < 8){
		alert('Pass >= 8 character');
		document.getElementById("pass_"+ref).focus();
		return false;
	}
	$.ajax({
		type : 'POST',
		url: url,
		data:data,
		dataType:'html',
		success: function(result){
			if(result==1){
				alert('Update Member Successfull');
				window.location.reload(true);
			}else{
				alert('Error connect to DB');
			}
		}
	});//end ajax	
}
function denymember(id){
	var r=confirm("Are you sure Deny Member! ");
	if (r==true){
		url = "<?php echo base_url()?>/addmincont/denyMember/";
		var data ={ref:id};
		$.ajax({
			type : 'POST',
			url: url,
			data:data,
			dataType:'html',
			success: function(result){
				if(result==1){
					alert('Deny Member Successfull');
				}else{
					alert('Error connect to DB');
				}
			}
		});//end ajax
	}else{
		return false;
	}	
}
function allowmember(id){
	var r=confirm("Are you sure Allow Member! ");
	if (r==true){
		url = "<?php echo base_url()?>/addmincont/allowMember/";
		var data ={ref:id};
		$.ajax({
			type : 'POST',
			url: url,
			data:data,
			dataType:'html',
			success: function(result){
				if(result==1){
					alert('Allow Member Successfull');
				}else{
					alert('Error connect to DB');
				}
			}
		});//end ajax
	}else{
		return false;
	}	
}
</script>

<h2>Manager Member</h2>
<table>
	<tr>
		<th>
			User Name
		</th>
		<th>
			PassWord
		</th>
		<th>
			Email
		</th>
		<th>
			Phone
		</th>
		<th>
			Address
		</th>
		<th>
			Update
		</th>
		<th>
			Deny
		</th>
		<th>
			Allow
		</th>
	</tr>
	<?php 
	$row = count($member);
	for ($i=0;$i<$row;$i++){
		echo "<tr>";
			echo "<th>";
				echo $member[$i]['user_id'];
			echo "</th>";
			echo "<td>";
				echo "<input type='text' id='pass_".$member[$i]['id']."' value='".$member[$i]['pass_id']."' />";
			echo "</td>";
			echo "<td>";
				echo $member[$i]['email'];
			echo "</td>";
			echo "<td>";
				echo $member[$i]['phone'];
			echo "</td>";
			echo "<td>";
				echo $member[$i]['address'];
			echo "</td>";
			echo "<td>";
				echo "<input type='button' id='update_'".$member[$i]['id']." value='Update' onclick='updatecatmember(".$member[$i]['id'].");' />";
			echo "</td>";
			echo "<td>";
				echo "<input type='button' id='deny_'".$member[$i]['id']." value='Deny' onclick='denymember(".$member[$i]['id'].");' />";
			echo "</td>";
			echo "<td>";
				echo "<input type='button' id='allow_'".$member[$i]['id']." value='Allow' onclick='allowmember(".$member[$i]['id'].");' />";
			echo "</td>";
		echo "</tr>";
	}
	?>
</table>